package unit7;

import java.util.Scanner;

public class Test1 {

	public static void main(String[] args) {
	Scanner scanner = new Scanner(System.in);
	while(true) {
		System.out.print("请输入一个八位数【输入八个零退出系统】");
		String LuckNumStr=scanner.next();
		if ("00000000".equals(LuckNumStr)) {
			System.out.println("您选择了退出系统，欢迎下次光临！");
			break;
		}else if (LuckNumStr!=null) {
			if (LuckNumStr.length()!=8) {
				System.out.println("您输入的字符串是"+LuckNumStr.length()+"位，请重新输入！");
				continue;
			}
			boolean flag=true;
			for(int i=0;i<=LuckNumStr.length()-1;i++) {
				char c=LuckNumStr.charAt(i);
				if (c<'0'||c>'9') {
					flag=false;
					break;
				}
			}
			if (flag) {
				if(LuckNumStr.charAt(0)=='0') {
					System.out.println("最高位是0，请重新输入！");
					continue;
				}
				long luckNum=Long.parseLong(LuckNumStr);
				int sum=0;
				do {
					sum+=luckNum%10;
					luckNum/=10;
				} while (luckNum!=0);
				System.out.println("累加合是："+sum);
				if (sum%7==0) {
					System.out.println("中奖了！");
				}else {
					System.out.println("没中奖！");
				}
			}
			
				
				else {
				System.out.println("您输入了非法数字，请重新输入");
				//continue;
			}
	}
		}
	}
	

}

